package com.tool.btn;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.MouseEvent;

import javax.swing.SwingConstants;

import org.come.Frame.ExchangeAwardJframe;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.DreamlandTrialMainJpanel;
import org.come.shortcut.XBjczJpanel;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.FormsManagement;

public class DreamlandTrialBtn extends MoBanBtn{
    private static final long serialVersionUID = 4456878086173461936L;
    private int caozuo;
    private DreamlandTrialMainJpanel dreamlandTrialMainJpanel;

    public DreamlandTrialBtn(final String iconpath, final int type, final int caozuo, final DreamlandTrialMainJpanel dreamlandTrialMainJpanel) {
        super(iconpath, type);
        this.caozuo = caozuo;
        this.dreamlandTrialMainJpanel = dreamlandTrialMainJpanel;
    }

    public DreamlandTrialBtn(final String iconpath, final int type, final Color[] colors, final Font font, final String text, final int caozuo, final DreamlandTrialMainJpanel dreamlandTrialMainJpanel) {
        super(iconpath, type, colors);
        this.setText(text);
        this.setFont(font);
        this.setHorizontalTextPosition(0);
        this.setVerticalTextPosition(0);
        this.caozuo = caozuo;
        this.dreamlandTrialMainJpanel = dreamlandTrialMainJpanel;
    }

    @Override
    public void chooseyes() {
    }

    @Override
    public void chooseno() {
    }

    @Override
    public void nochoose(final MouseEvent e) {
        if (this.caozuo == 0) {//首页
            if (this.dreamlandTrialMainJpanel.getPageNow() <= 1) {
                ZhuFrame.getZhuJpanel().addPrompt2("已经是首页了");
                return;
            }
            else {
                this.dreamlandTrialMainJpanel.showLvlTier(Integer.valueOf(1));
            }
        }
        else {
            if (this.caozuo == 1) {//上一页
                if (this.dreamlandTrialMainJpanel.getPageNow() <= 1) {
                    ZhuFrame.getZhuJpanel().addPrompt2("已经是首页了");
                    return;
                }
                else {
                    this.dreamlandTrialMainJpanel.showLvlTier(Integer.valueOf(this.dreamlandTrialMainJpanel.getPageNow() - 1));
                }
            }
            else {
                if (this.caozuo == 2) {//下一页
                    if (this.dreamlandTrialMainJpanel.getPageNow() >= this.dreamlandTrialMainJpanel.getPageMax()) {
                        ZhuFrame.getZhuJpanel().addPrompt2("已经是末页了");
                        return;
                    }
                    else {
                        this.dreamlandTrialMainJpanel.showLvlTier(Integer.valueOf(this.dreamlandTrialMainJpanel.getPageNow() + 1));
                    }
                }
                else {
                    if (this.caozuo == 3) {//末页
                        if (this.dreamlandTrialMainJpanel.getPageNow() >= this.dreamlandTrialMainJpanel.getPageMax()) {
                            ZhuFrame.getZhuJpanel().addPrompt2("已经是末页了");
                            return;
                        }
                        else {
                            this.dreamlandTrialMainJpanel.showLvlTier(Integer.valueOf(this.dreamlandTrialMainJpanel.getPageMax()));
                        }
                    }
                    else {
                        if (this.caozuo == 4) {//开始挑战
                            if (this.dreamlandTrialMainJpanel.getChooseNum() == -1) {
                                ZhuFrame.getZhuJpanel().addPrompt2("请先选择关卡");
                                return;
                            }
                            else {
                                final int num = (this.dreamlandTrialMainJpanel.getPageNow() - 1) * 6 + this.dreamlandTrialMainJpanel.getChooseNum() + 1;
                                FormsManagement.HideForm(3100);
                                SendMessageUntil.toServer(Agreement.getAgreement().hjslAgreement("P" + num));
                            }
                        }
                        else {
                            if (this.caozuo == 5) {//招募高手
                                ExchangeAwardJframe.getExchangeAwardJframe().getAwardJpanel().use(5, null);
                            }
                            else {
                                if (this.caozuo == 6) {//添加次数
                                    this.dreamlandTrialMainJpanel.showLvlTier(Integer.valueOf(1));
                                    SendMessageUntil.toServer(Agreement.getAgreement().hjslAgreement("R"));
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
